﻿
@model ARPAMIS.Presentation.Web.Models.ViewModels.ListStudentViewModel
@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section JavaScriptRender
{

@Html.Raw(ARPAMIS.Presentation.Web.WebHelpers.ViewComponents.GetJqGridComponents())

<script type="text/javascript">
    $(function () {

        $("#dataTable").jqGrid({
            url: '@Url.Content("~/Student/GetStudentList")',
            datatype: 'json',
            type: 'GET',
            colNames: ['StudentNumber','FirstName', 'MiddleName', 'LastName', ""],
            colModel: [
            { name: 'StudentNumber', index: 'StudentNumber' },
        { name: 'FirstName', index: 'FirstName' },
        { name: 'MiddleName', index: 'MiddleName' },
        { name: 'LastName', index: 'LastName' },
        { name: 'link', index: 'link' }
        ],
            //Map the reader as we are using standard JSON format, not the standard jqgrid format
            jsonReader: {
                page: "page",
                total: "total",
                records: "records",
                root: "rows",
                repeatitems: false,
                id: "EntityId"
            },
            pager: '#pager',
            rowNum: 15,
            sortname: 'StudentNumber',
            rowList: [15, 30, 45,50,55,60,65,70],
            height: 300,
            width: 1050,
            scrollOffset: 2,
            viewrecords: true,
            sortorder: "desc",
            postData: {
                firstName: function () { return $("#FirstName").val(); },
                middleName: function () { return $("#MiddleName").val(); },
                lastName: function () { return $("#LastName").val(); }
            }
        });
        $("#searchButton").click(function () { $("#dataTable").trigger("reloadGrid"); });

    });
</script>
}

@using (Html.BeginForm())
{
    @Html.Raw(Model.Message)
    
    <fieldset>
        <legend>Search</legend>
        <div class="searchBlock">
            <table>
                <tr>
                    <td>
                        @Html.LabelFor(f => f.FirstName)
                    </td>
                    <td>
                        @Html.TextBoxFor(f => f.FirstName)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(m => m.MiddleName)
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.MiddleName)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(l => l.LastName)
                    </td>
                    <td>
                        @Html.TextBoxFor(l => l.LastName)
                    </td>
                </tr>
            </table>
            
        </div>
    </fieldset>
    
    <div style="margin: 7px 7px 0px 0px; height:80px;">
    <input type="button" value="Search" id="searchButton" class="buttonStyle ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
        @*<input type="submit" value="Search" name="action" id="searchStudent" class="buttonStyle ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />*@
        <input type="submit" value="Add" name="action" id="AddStudent" class="buttonStyle ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
    </div>
    
    <div class='resultblock' style="clear: both;">
        <fieldset>
            <legend>Student List</legend>
            <table id="dataTable">
             @*   <thead>
                    <tr>
                        <th>
                            Student Number
                        </th>
                        <th>
                            First Name
                        </th>
                        <th>
                            Last Name
                        </th>
                        <th>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var stud in Model.Students)
                    {
                        <tr>
                            <td>
                                @stud.ControlNumber
                            </td>
                            <td>
                                @stud.FirstName
                            </td>
                            <td>
                                @stud.LastName
                            </td>
                            <td class="gridLinkColumn">
                            @Html.ActionLink("View", "Register", new { @id = stud.EntityId }, new { @class = "gridLinks" })
                            </td>
                        </tr>
                    }
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="4">
                            &nbsp;
                        </td>
                    </tr>
                </tfoot>*@
            </table>
            <div id="pager"></div>
        </fieldset>
    </div>
    <div style="clear:both;" />
    
}

